package st.business.tepth.business.visitor.visitorwork;

import st.business.tepth.base.OnDataConvertListener;
import st.business.tepth.business.bean.BusRepairBean;

/**
 * @author zhangyu
 * @date 2019/3/5
 */
public class VisitorWorkPresenter extends VisitorWorkContract.Presenter {
    private final VisitorWorkContract.View mView;
    private final VisitorWorkContract.Model mModel;

    public VisitorWorkPresenter(VisitorWorkContract.View view) {
        mView = view;
        mModel = new VisitorWorkModel();
    }

    @Override
    void getBusInfo(int id) {
        addDisposable(mModel.getBusInfo(id, new OnDataConvertListener<BusRepairBean>() {
            @Override
            public void convert(BusRepairBean locationBean) {
                if (mView != null) {
                    mView.showBusInfo(locationBean);
                }
            }

            @Override
            public void error(int code, String msg) {
                if (mView != null) {
                    mView.showBusInfo(null);
                }
            }
        }));
    }
}
